import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author LKQ
 * @date 2022/2/16 13:22
 * @description hash
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {1, 3, 5, 3};
        solution.findLonely(nums);
    }
    public List<Integer> findLonely(int[] nums) {
        List<Integer> ans = new ArrayList<>();
        Map<Integer, Integer> map = new HashMap<>();
        for (int num: nums) {
            map.put(num, map.getOrDefault(num, 0) + 1);
        }
        for (int key: map.keySet()) {
            if ( map.get(key) == 1 && !map.containsKey(key - 1) && !map.containsKey(key + 1)) {
                ans.add(key);
            }
        }
        return ans;
    }
}
